package com.rookie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rookie.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.ServletRequestUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * 公共前端控制器
 */
public class BaseController {

    @Autowired
    HttpServletRequest request;
    @Autowired
    BCryptPasswordEncoder bCryptPasswordEncoder;
    @Autowired
    UserService userService;
    @Autowired
    RoleService roleService;
    @Autowired
    MenuService menuService;
    @Autowired
    RoleMenuService roleMenuService;
    @Autowired
    UserRoleService userRoleService;

    /**
     * 查询分页
     */
    public Page getPage() {
        long current = ServletRequestUtils.getLongParameter(request, "current", 1);
        long size = ServletRequestUtils.getLongParameter(request, "size", 10);
        return new Page<>(current, size);
    }

}
